import 'package:flutter/material.dart';
import 'package:get/get.dart';

import '../../../dd_core/dd_http.dart';
import '../../../dd_core/dd_log_service.dart';
import '../../../dd_core/dd_other.dart';
import '../../../r.dart';
import '../../dd_launch_and_main/pages/dd_web_page.dart';
import '../controllers/dd_personal_center_controller.dart';
import '../views/dd_view_background.dart';

class DDAboutPage extends StatefulWidget {
  const DDAboutPage({Key? key}) : super(key: key);

  @override
  State<DDAboutPage> createState() => _DDAboutPageState();
}

class _DDAboutPageState extends State<DDAboutPage> {
  DDPersonalCenterController _controller =
      Get.find<DDPersonalCenterController>();

  @override
  Widget build(BuildContext context) {
    return GetBuilder<DDPersonalCenterController>(
        init: _controller,
        initState: (state) {
          DDLogService().ddGa(page: "about");
        },
        dispose: (state) {},
        builder: (controller) {
          return Scaffold(
            appBar: AppBar(
              backgroundColor: Color(0xFFE7F6FC),
              title: Text(
                'About',
                style: TextStyle(fontSize: 18),
              ),
              leading: IconButton(
                icon: Image.asset(R.assetsImagesHomeSecond1),
                onPressed: () {
                  Get.back();
                },
              ),
            ),
            backgroundColor: Color(0xFFE7F6FC),
            body: Stack(
              children: [
                Positioned.fill(
                  child: Image.asset(
                    R.assetsImagesPerson20,
                    fit: BoxFit.fill,
                  ),
                ),
                SafeArea(
                  top: false,
                  child: Align(
                    alignment: Alignment.topCenter,
                    child: SingleChildScrollView(
                      child: Padding(
                        padding: const EdgeInsets.all(16.0),
                        child: Column(
                          children: [
                            SizedBox(
                              height: 37,
                            ),
                            GestureDetector(
                              onTap: () {},
                              child: DDViewBackGround(
                                borderRadius: 16,
                                content: ClipRRect(
                                  borderRadius: BorderRadius.circular(14.0),
                                  child: Image.asset(
                                    R.assetsImagesAppLogo,
                                    width: 88,
                                    height: 88,
                                  ),
                                ),
                              ),
                            ),
                            SizedBox(
                              height: 12,
                            ),
                            Text(
                              'SabreSync',
                              style: TextStyle(
                                  fontSize: 16, fontWeight: FontWeight.bold),
                            ),
                            SizedBox(
                              height: 14,
                            ),
                            Text(
                              'Version ${DDAppInfo.getInstance().version}',
                              style: TextStyle(
                                  fontSize: 12, color: Color(0xFF53BFD7)),
                            ),
                            SizedBox(
                              height: 32,
                            ),
                            ProfileStyle3MenuItem(
                              title: "Terms and Conditons",
                              onTap: () {
                                Get.to(() => DDWebViewPage(
                                      url: termConditionsUrl,
                                      title: "Terms and Conditons",
                                    ));
                              },
                            ),
                            SizedBox(
                              height: 14,
                            ),
                            ProfileStyle3MenuItem(
                              title: "Privacy Policy",
                              onTap: () {
                                Get.to(() => DDWebViewPage(
                                      url: privacyPolicyUrl,
                                      title: "Privacy Policy",
                                    ));
                              },
                            ),
                            SizedBox(
                              height: 14,
                            ),
                          ],
                        ),
                      ),
                    ),
                  ),
                ),
              ],
            ),
          );
        });
  }
}

class ProfileStyle3MenuItem extends StatelessWidget {
  final String title;
  final VoidCallback onTap;

  ProfileStyle3MenuItem({
    required this.title,
    required this.onTap,
  });

  @override
  Widget build(BuildContext context) {
    return DDViewBackGround(
      margin: const EdgeInsets.only(top: 10, bottom: 10, left: 32, right: 32),
      content: ListTile(
        leading: Text(
          title,
          style: TextStyle(fontSize: 16, color: Color(0xFF404040)),
        ),
        onTap: onTap,
      ),
    );
  }
}
